package com.wangyadong.hobby.schedule.jobtask.thread.thread1;

public class TicketThread2 implements Runnable {

    private static int index;

    public TicketThread2() {
        super();
    }

    @Override
    public synchronized void run() {
        while (index < 50) {
            System.out.println(Thread.currentThread().getName() + " has " + (++index));
        }
    }

    public static void main(String[] args) {
        TicketThread2 ticket1 = new TicketThread2();
        TicketThread2 ticket2 = new TicketThread2();
        TicketThread2 ticket3 = new TicketThread2();
        TicketThread2 ticket4 = new TicketThread2();
        new Thread(ticket1).start();
        new Thread(ticket2).start();
        new Thread(ticket3).start();
        new Thread(ticket4).start();

    }
}
